 
    
    EstimateACE = function(N,eX,Z,Y,Yhat1,Yhat0,X){
        return(c(HT(N,eX,Z,Y), Ratio(N,eX,Z,Y), DR(N,eX,Z,Y,Yhat1,Yhat0),
                 Imb(N,eX,Z,X)))
    }
    
    ACEst = function(Z,X.prop,X.or,Y,N){
        
        results = array(NA,c(length(Estimators.cand)))
        dimnames(results) = list(Estimator = Estimators.cand)
        
        # outcome regression
        Y1 = Y[Z==1]
        X.or1 = X.or[Z==1,]
        Y0 = Y[Z==0]
        X.or0 = X.or[Z==0,]
        
        lm.sol1 = lm(Y1~X.or1)
        lm.sol0 = lm(Y0~X.or0)
        Yhat1  = cbind(1,X.or)%*%(lm.sol1$coefficients)
        Yhat0  = cbind(1,X.or)%*%(lm.sol0$coefficients)
        
            results.eX = eXEst(Z,X.prop)
            eX = results.eX
            if ((sum(eX==0, na.rm = TRUE) + sum(eX==1, na.rm = TRUE))==0){
            results[] = tryCatch(EstimateACE(N,eX,Z,Y,Yhat1,Yhat0,X.prop),error = function(e) rep(NA, 4))
            }else{
            results[] = rep(NA, 4)
            }
            
        
        return(results)
        
    }
    
    
    
    
    
    
    
